<?php

class Core_Agent_Component_Customer_Controller_Index extends Dcmp_Component_Controller {

    public function indexAction($pageindex = 1){
        $this->getHistory()->record();
        $validator = $this->getRequest()->getValidator('filter');
        $query = App::getModel('foundation/collection_poi');
        if(!$this->getIdentity()->isSuperAdmin()){
			$query->innerJoin('{t}account_poi', 'e', 'e.poi_id', 'a.id')
				  ->eq('e.account_id', $this->getIdentity()->getId());
        }
        
        if ($validator->isNotEmpty('poiid')) {
            $query->contain('id', ':id:s')->addParameter('id', '%' . $validator->getValue('poi_id') . '%');
        }
        if ($validator->isNotEmpty('shopname')) {
            $query->like('shop_name', ':shopName:s')->addParameter('shopName', '%' . $validator->getValue('shopname') . '%');
        }
        $list = $query->pagination($pageindex, 20)->load();
        $records = $query->loadCount();
        return $this->viewResult(array('list' => $list, 'records' => $records));
    }
}